package com.example.itensyuan0609.fragment;


import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.Switch;

import androidx.fragment.app.Fragment;

import com.example.itensyuan0609.R;

import static android.content.Context.MODE_PRIVATE;

/**
 * A simple {@link Fragment} subclass.
 */
public class ThreeFragment extends Fragment {
    Switch aSwitch;

    public ThreeFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(final LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View v = inflater.inflate(R.layout.fragment_three, container, false);
        aSwitch = v.findViewById(R.id.sw);
        aSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                SharedPreferences isL = getContext().getSharedPreferences("isLoad", MODE_PRIVATE);
                SharedPreferences.Editor edit = isL.edit();
                edit.putBoolean("is", b);
                edit.commit();
            }
        });
        return v;

    }

}
